package structtest

import "fmt"

func Execute() {
	TestStruct()
}

func TestStruct() {

	person1 := new(Person)
	person1.name = "name1"

	person2 := &Person{}
	person2.name = "name2"

	person := Person{
		name:   "姓名",
		age:    18,
		gender: "male",
		legs: []Leg{
			{
				length: 10,
			},
			{
				length: 10,
			},
		},
		hands: []Hand{
			{
				length: 5,
			},
			{
				length: 5,
			},
		},
		face: Face{
			name: "face",
		},
		other: &Other{
			name: "other",
		},
	}

	worker1 := Worker{workType: "coder", Person: person}
	worker1.say()
	worker1.Person.say()
}

type Worker struct {
	workType string
	Person
}

type Leg struct {
	length int
}

type Hand struct {
	length int
}

type Face struct {
	name string
}

type Other struct {
	name string
}

type Person struct {
	name, gender string
	age          int
	legs         []Leg
	hands        []Hand
	face         Face
	other        *Other
}

func (Person *Person) rename() {
	Person.name = "新名字"
}

func (person Person) say() {
	fmt.Printf("my name is: %v\n", person.name)
}

func (worker *Worker) say() {
	worker.Person.say()
	fmt.Printf("worker name is: %v\n", worker.name)
}
